import ReactDOM from 'react-dom';
import React, { Component } from 'react';
import {Provider} from 'mobx-react';
// 载入默认全局样式 normalize
import '@alifd/next/reset.scss';
import AppStore from '#/stores/AppStore';
import DictStore from '#/stores/DictStore';
import UserStore from '#/stores/UserStore';
import router from './router';

const ICE_CONTAINER = document.getElementById('ice-container');

if (!ICE_CONTAINER) {
  throw new Error('当前页面不存在 <div id="ice-container"></div> 节点.');
}

class GlobalStoreWrapper extends Component {

  componentDidMount() {
    //TODO: can do some permission things
  }

  render() {
    return (
     <Provider 
      appstore={AppStore}
      userstore={UserStore}
      dictstore={DictStore} >
        {router}
      </Provider>
    );
  }
}

ReactDOM.render(< GlobalStoreWrapper />, ICE_CONTAINER);
